﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spaanjaars.ContactManager.Infrastructure.Domain;
using Spaanjaars.ContactManager.Infrastructure.Validation;

namespace Spaanjaars.ContactManager.Model
{
    public class Name : ValueObject<Name>
    {
        private Name()
        {
        }

        public Name(string firstName, string lastName)
            : this(firstName, String.Empty, lastName)
        {         
        }

        public Name(string firstName, string middleName, string lastName)
        {
            FirstName = firstName;
            LastName = lastName;
            MiddleName = middleName;
        }

        public string FirstName { get; private set; }

        public string LastName { get; private set; }

        public string MiddleName { get; private set; }

        public string FullName 
        {
            get
            {
                if (String.IsNullOrEmpty(MiddleName))
                    return String.Format("{0} {1}", FirstName, LastName);
                else
                {
                    return String.Format("{0} {1} {2}", FirstName, MiddleName, LastName);
                }
            }
        }

        public override string ToString()
        {
            return FullName;
        }

        public override IEnumerable<IBrokenRule> GetBrokenRulesFor(IDomainObjectValidator<Name> domainObjectValidator)
        {
            throw new NotImplementedException();
        }

        public override IEnumerable<IBrokenRule> GetBrokenRules()
        {
            throw new NotImplementedException();
        }
    }
}
